package com.qd.pay.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cdqidi.db.BaseService;
import com.qd.pay.mapper.TfBillsTimeMapper;
import com.qd.pay.model.TfBillsTime;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 天府银行总交易信息
 *
 * @author sjk
 */
@RequiredArgsConstructor
@Service
@Slf4j
public class TfBillsTimeService extends BaseService<TfBillsTimeMapper, TfBillsTime> {

    /**
     * 根据唯一性索引获得数据
     * <p>
     * param partner
     * param orderDate
     *
     * @return 单条数据
     */
    @Transactional(readOnly = true)
    public TfBillsTime getUniqueByPartnerAndOrderDate(String partner, String orderDate) {
        final QueryWrapper<TfBillsTime> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("partner", partner);
        queryWrapper.eq("order_date", orderDate);
        TfBillsTime tfBillsTime = super.getOne(queryWrapper, false);
        queryWrapper.clear();
        return tfBillsTime;
    }
}